package com.jf.cloud.service.sysmanager.common.util;

import java.util.regex.Pattern;

/**
 * 正则校验工具类
 * 
 * @author duaichao 创建时间：2012-04-27 11:35:17
 */
@SuppressWarnings("all")
public class RegexValidUtil {
	public final static String decmal = "^([+-]?)\\d*\\.\\d+$";	//浮点数
	public final static String decmal1 = "^[1-9]\\d*.\\d*|0.\\d*[1-9]\\d*$";	//正浮点数
	public final static String decmal2 = "^-([1-9]\\d*.\\d*|0.\\d*[1-9]\\d*)$";	//负浮点数
	public final static String decmal3 = "^-?([1-9]\\d*.\\d*|0.\\d*[1-9]\\d*|0?.0+|0)$";	//浮点数
	public final static String decmal4 = "^[1-9]\\d*.\\d*|0.\\d*[1-9]\\d*|0?.0+|0$";	//非负浮点数（正浮点数 + 0）
	public final static String decmal5 = "^(-([1-9]\\d*.\\d*|0.\\d*[1-9]\\d*))|0?.0+|0$";	//非正浮点数（负浮点数 + 0）
	public final static String intege = "^-?[1-9]\\d*$";	//整数
	public final static String intege1 = "^[1-9]\\d*$";	//正整数
	public final static String intege2 = "^-[1-9]\\d*$";	//负整数
	public final static String num = "^([+-]?)\\d*\\.?\\d+$";	//数字
	public final static String num1 = "^[1-9]\\d*|0$";	//正数（正整数 + 0）
	public final static String num2 = "^-[1-9]\\d*|0$";	//负数（负整数 + 0）
	public final static String ascii = "^[\\x00-\\xFF]+$";	//仅ACSII字符
	public final static String chinese = "^[\\u4e00-\\u9fa5]+$";	//仅中文
	public final static String color = "^[a-fA-F0-9]{6}$";	//颜色
	public final static String date = "^\\d{4}(\\-|\\/|\\.)\\d{1,2}\\1\\d{1,2}$";	//日期
	public final static String email = "^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$";	//邮件
	public final static String idcard = "^[1-9]([0-9]{14}|[0-9]{17})$";	//身份证
	public final static String ip4 = "^(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)$";	//ip地址
	public final static String letter = "^[A-Za-z]+$";	//字母
	public final static String letter_l = "^[a-z]+$";	//小写字母
	public final static String letter_u = "^[A-Z]+$";	//大写字母
	//public final static String 	mobile = "^0?(13|15|18)[0-9]{9}$";	//手机
	public final static String mobile = "^1[3456789]\\d{9}$";	//手机
	public final static String notempty = "^\\S+$";	//非空
	public final static String password = "^[A-Za-z0-9_-]+$";	//密码
	public final static String picture = "(.*)\\.(jpg|bmp|gif|ico|pcx|jpeg|tif|png|raw|tga)$";	//图片
	public final static String qq = "^[1-9]*[1-9][0-9]*$";	//QQ号码
	public final static String rar = "(.*)\\.(rar|zip|7zip|tgz)$";	//压缩文件
	public final static String tel = "^[0-9\\-()（）]{7,18}$";	//电话号码的函数(包括验证国内区号,国际区号,分机号)
	public final static String url = "^http[s]?:\\/\\/([\\w-]+\\.)+[\\w-]+([\\w-./?%&=]*)?$";	//url
	public final static String username = "^[A-Za-z0-9_\\-\\u4e00-\\u9fa5]+$";	//用户名
	public final static String deptname = "^[A-Za-z0-9_()（）\\-\\u4e00-\\u9fa5]+$";	//单位名
	public final static String zipcode = "^\\d{6}$";	//邮编
	public final static String realname = "^[A-Za-z\\u4e00-\\u9fa5]+$";  // 真实姓名
	public final static String companyname = "^[A-Za-z0-9_()（）\\-\\u4e00-\\u9fa5]+$";
	public final static String companyaddr = "^[A-Za-z0-9_()（）\\#\\-\\u4e00-\\u9fa5]+$";
	public final static String companysite = "^http[s]?:\\/\\/([\\w-]+\\.)+[\\w-]+([\\w-./?%&#=]*)?$";
	public final static String invitecode = "^[A-Za-z0-9]{6}$";//验证邀请码格式
	
	public static boolean compile(String regEx, String str){
		return Pattern.compile(regEx).matcher(str).find();
	}


}
